package com.zj.osm.view.mine;

import android.annotation.SuppressLint;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.zj.osm.R;

import java.util.List;




/**
 * 关于的适配器
 */

public class AboutAdapter extends ArrayAdapter<String> {

    private LayoutInflater mLayoutInflater;
    private int resourceId;


    public AboutAdapter(Context context, int resourceId, List<String> objects) {
        super(context, resourceId, objects);

        //获取LayoutInflater 服务,用来从预定义的xml布局创建view对象.
        this.resourceId = resourceId;

        mLayoutInflater = LayoutInflater.from(context);
    }

    @NonNull
    @SuppressLint("SetTextI18n")
    @Override
    public View getView(int position, View convertView, @NonNull ViewGroup parent) {
        if (convertView == null) {
            //创建新的view视图.
            convertView = mLayoutInflater.inflate(resourceId, null);
        }
        String person = getItem(position);
        TextView name = convertView.findViewById(R.id.name);
        if (position == 0) {
            name.setText("\n\n" + person + "\n");
        } else {
            name.setText("\n" + person);
        }
        return convertView;
    }
}
